const Mock = require("mockjs");
const quote = require("./quote.json");
// mock里的方法必须小写;
Mock.mock("/news/article", "get", () => {
  return {
    state: "ok",
    data: {
      title: "这是新闻",
      content: "这是新闻的内容",
    },
  };
});

Mock.mock("http://www.baidu.com/api", "get", () => {
  let hotLevel = new Array(parseInt(Math.random() * 10 + 1)).fill("★").join("");
  return {
    state: "ok",
    data: {
      hotLevel: hotLevel,
      title: "这是新闻",
      content: "这是新闻的内容",
      // title: Mock.Random.ctitle(1, 5),
      category: Mock.Random.cword(1, 5),
      newsLink: Mock.Random.url(),
      anthor: Mock.Random.cname(),
      province: Mock.Random.province(),
      city: Mock.Random.city(),
    },
  };
});

Mock.mock("http://www.baidu.com/api", "get", {
  state: "ok",
  "level|1-10": "★",
  articleImage: Mock.Random.image("200x200", "#ff6600", "新闻封面"),
  themeColor: Mock.Random.color(),
  //   content: Mock.Random.paragraph(1, 3),
  content: Mock.Random.cparagraph(1, 3),
  //   title: Mock.Random.sentence(1, 5),
  //   category: Mock.Random.word(1, 5),
  //   title: Mock.Random.title(1, 5),
  title: Mock.Random.ctitle(1, 5),
  category: Mock.Random.cword(1, 5),
  newsLink: Mock.Random.url(),
  anthor: Mock.Random.cname(),
  province: Mock.Random.province(),
  city: Mock.Random.city(),
});

// 导航列表
Mock.mock("http://api.cpengx.cn/finance/api/nav/navList", "get", () => {
  return {
    msg: "OK",
    result: [
      { title: "大盘行情", imgSrc: "./imgs/nav1.png", linkTo: "" },
      { title: "股票组合", imgSrc: "./imgs/nav2.png", linkTo: "" },
      { title: "股票开户", imgSrc: "./imgs/nav3.png", linkTo: "" },
      { title: "选股攻略", imgSrc: "./imgs/nav4.png", linkTo: "" },
      { title: "指数选基", imgSrc: "./imgs/nav5.png", linkTo: "" },
      { title: "基金组合", imgSrc: "./imgs/nav6.png", linkTo: "" },
      { title: "私募基金", imgSrc: "./imgs/nav7.png", linkTo: "" },
      { title: "基金必看", imgSrc: "./imgs/nav8.png", linkTo: "" },
    ],
  };
});

Mock.mock("http://api.cpengx.cn/finance/api/quote", "get", () => {
  return quote;
});
